package org.funny.machine32.hardware.processors;

import org.funny.machine32.hardware.common.HardwareComponentEnum;
import org.funny.machine32.hardware.common.IHardwareComponent;
import org.funny.machine32.hardware.common.IReadable;
import org.funny.machine32.hardware.common.IWritable;

import java.util.List;

public class Register implements IHardwareComponent, IReadable, IWritable {
    private String name;
    protected int data;

    public Register(String name) {
        data = 0;
        this.name = name;
    }

    public String getName() {
        return name;
    }

    public String getComponentName() {
        return HardwareComponentEnum.REGISTER.getName();
    }

    @Override
    public List<IHardwareComponent> getSubComponents() {
        return null;
    }

    @Override
    public void reset() {
        data = 0;
    }

    public int read() {
        return data;
    }

    public void write(int value) {
        data = value;
    }
}
